/**
 * Copyright:Copyright(c)2014-2017
 * Company:厦门市易致达物联网科技有限公司
 * @version 1.0
 */
package shop.controller.manage.balance;
import shop.core.common.bean.JSONResult;
import shop.core.common.dao.page.PagerModel;
import shop.core.util.KeyValueHelper;
import shop.core.Services;
import shop.core.util.MD5;
import shop.services.manage.balance.BalanceService;
import shop.services.manage.balance.bean.Balance;
import shop.core.BaseController;
import shop.core.RequestHolder;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**   
 * @类名称：BalanceAction      
 * @创建人：wzl
 * @创建时间：2018-01-03 下午16:30:00      
 * @版本号：1.0
 * @描述：     
 */
@Controller
@RequestMapping("/manage/balance/")
public class BalanceAction extends BaseController<Balance> {
    private static final Logger logger = LoggerFactory.getLogger(BalanceAction.class);
    @Autowired
    private BalanceService balanceService;
    private static final String page_toList = "/manage/balance/balanceList";
    public BalanceService getService() {
        return balanceService;
    }

    private BalanceAction(){
        super.page_toList = page_toList;
        super.page_toAdd = null;
        super.page_toEdit = null;
    }

    /**
     * 查询用户充值记录列表
     *
     * @param request 请求
     * @param balance       对象参数
     * @return 分页数据模型
     */
    @RequestMapping("selectBalancePage")
    @ResponseBody
    public PagerModel selectBalancePage(HttpServletRequest request, Balance balance){
        int offset = 0;
        int pageSize = 10;
        int start=Integer.parseInt(request.getParameter("start"));
        int length= Integer.parseInt(request.getParameter("length"));
        if(start>0)
            offset=start;
        if(length>0)
            pageSize=length;
        balance.setOffset(offset);
        balance.setPageSize(pageSize);
        PagerModel pager = balanceService.selectBalancePage(balance);
        pager.setRecordsTotal(pager.getTotal());
        pager.setRecordsFiltered(pager.getTotal());
        return pager;
    }

}
